<?php
namespace app\modules\Front\controllers;

use yii;
use app\modules\Order\models\Order;
use app\modules\Product\models\Product;
use app\components\GetToken;
use yii\web\Controller;


class TestController extends Controller
{


	/**
     * 订单占位过期消息通知 测试
     * 
     */
    public  function actionTest()
    {
      
        // 获取所有设置占位时间 未发船
        $data = Product::find()->select("id,go_time,date_limit")->where(['status'=>1])->andWhere(['>','go_time', date('Y-m-d')])->all();

    }

    //发送post请求
    private function request_post($url = '', $param = '')
    {
        if (empty($url) || empty($param)) {
            return false;
        }
        $postUrl = $url;
        $curlPost = $param;
        $ch = curl_init(); //初始化curl
        curl_setopt($ch, CURLOPT_URL, $postUrl); //抓取指定网页
        curl_setopt($ch, CURLOPT_HEADER, 0); //设置header
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //要求结果为字符串且输出到屏幕上
        curl_setopt($ch, CURLOPT_POST, 1); //post提交方式
        curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost);
        $data = curl_exec($ch); //运行curl
        curl_close($ch);
        return $data;
    }
    

    //发送get请求
    private function request_get($url){
        if(empty($url)) {
            return false;
        }
        $data = '';
        $getUrl = $url;
        $ch = curl_init();
        //设置选项，包括URL
        curl_setopt($ch, CURLOPT_URL, $getUrl);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        //执行并获取HTML文档内容
        $output = curl_exec($ch);
        //释放curl句柄
        curl_close($ch);
        //打印获得的数据
        return $output;
    }

    //xdoc 测试
    public function actionXdoc(){
        $url = "http://www.xdocin.com/xdoc?_func=hi&_rformat=json";

        $url2 = "http://www.xdocin.com/xdoc?_func=acc&_key=bsqt2stk75h6bgejtyy3wrposu&_rformat=json";

        $res = $this->request_get($url2);

        var_dump($res);
    }


   


}
